import { IPSMDAjaxControlHandler } from './ipsmdajax-control-handler';
import { PSAjaxControlHandlerImpl } from './psajax-control-handler-impl';
import { IPSSysUserDR } from '../../security/ipssys-user-dr';

export class PSMDAjaxControlHandlerImpl extends PSAjaxControlHandlerImpl implements IPSMDAjaxControlHandler {
  get customDRMode2Param(): string {
    return this.M.customDRMode2Param;
  }

  get customDRModeParam(): string {
    return this.M.customDRModeParam;
  }

  get fetchTimeout(): number {
    return this.M.fetchTimeout != null ? this.M.fetchTimeout : -1;
  }

  get orgDR(): 1 | 2 | 4 | 8 {
    return this.M.orgDR != null ? this.M.orgDR : 0;
  }

  protected pssysuserdr: IPSSysUserDR | null = null;

  getPSSysUserDR(): IPSSysUserDR | null {
    if (this.pssysuserdr != null) return this.pssysuserdr;
    const value = this.M.getPSSysUserDR;
    if (value == null) {
      return null;
    }
    this.pssysuserdr = this.getPSModel4('security.IPSSysUserDR', value, 'getPSSysUserDR') as IPSSysUserDR;
    return this.pssysuserdr;
  }

  get psSysUserDR(): IPSSysUserDR | null {
    return this.getPSSysUserDR();
  }

  getPSSysUserDRMust(): IPSSysUserDR {
    const value = this.getPSSysUserDR();
    if (value == null) {
      throw new Error('未指定用户数据范围对象');
    }
    return value;
  }

  protected pssysuserdr2: IPSSysUserDR | null = null;

  getPSSysUserDR2(): IPSSysUserDR | null {
    if (this.pssysuserdr2 != null) return this.pssysuserdr2;
    const value = this.M.getPSSysUserDR2;
    if (value == null) {
      return null;
    }
    this.pssysuserdr2 = this.getPSModel4('security.IPSSysUserDR', value, 'getPSSysUserDR2') as IPSSysUserDR;
    return this.pssysuserdr2;
  }

  get psSysUserDR2(): IPSSysUserDR | null {
    return this.getPSSysUserDR2();
  }

  getPSSysUserDR2Must(): IPSSysUserDR {
    const value = this.getPSSysUserDR2();
    if (value == null) {
      throw new Error('未指定用户数据范围对象2');
    }
    return value;
  }

  get secBC(): string {
    return this.M.secBC;
  }

  get secDR(): 1 | 2 | 4 | 8 {
    return this.M.secDR != null ? this.M.secDR : 0;
  }

  get userDRAction(): string {
    return this.M.userDRAction;
  }

  get enableOrgDR(): boolean {
    return this.M.enableOrgDR != null ? this.M.enableOrgDR : false;
  }

  get enableSecBC(): boolean {
    return this.M.enableSecBC != null ? this.M.enableSecBC : false;
  }

  get enableSecDR(): boolean {
    return this.M.enableSecDR != null ? this.M.enableSecDR : false;
  }

  get enableUserDR(): boolean {
    return this.M.enableUserDR != null ? this.M.enableUserDR : false;
  }

  get cls(): string {
    return 'PSMDAjaxControlHandlerImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'control.ajax.IPSMDAjaxControlHandler') return true;
    return super.instanceof(cls);
  }
}
